package com.bgs.eat.rider.controller;

import com.bgs.eat.config.CommonResult;
import com.bgs.eat.rider.entity.dto.registeredRiderDto;
import com.bgs.eat.rider.service.riderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@Slf4j
@RequestMapping("/rider")
public class riderController {
    @Autowired
    private riderService riderService;

    /* *
     * @Author: beisheng
     * @Descriprion: 申请成为骑手
     * @Date: 2022/10/13 20:06
     * @Return: com.bgs.eat.config.CommonResult
     * @Param: [phone, code]
     */

    @PostMapping("/registeredRider")
    public CommonResult registeredRider(@RequestBody registeredRiderDto registeredRiderDto){
        return riderService.registeredRider(registeredRiderDto);
    }

    /* *
     * @Author: beisheng
     * @Descriprion: 验证验证码
     * @Date: 2022/10/14 8:56
     * @Return: com.bgs.eat.config.CommonResult
     * @Param: [phone, code]
     */

    @GetMapping("/verificationPhoneCode")
    public CommonResult verificationPhoneCode(String phone,String code,String codeMark){
        return riderService.verificationPhoneCode(phone,code,codeMark);
    }


   /* *
    * @Author: beisheng
    * @Descriprion: 用户修改密码
    * @Date: 2022/10/14 10:15
    * @Return: com.bgs.eat.config.CommonResult
    * @Param: [phone]
    */

    @GetMapping("/updatePassword")
    public CommonResult updatePassword(String phone,String newPassword){
        return riderService.updatePassword(phone,newPassword);
    }

    /* *
     * @Author: beisheng
     * @Descriprion: 修改骑手状态【上线-1,下线-0】
     * @Date: 2022/10/21 13:58
     * @Return: com.bgs.eat.config.CommonResult
     * @Param: [phone, name]
     */

    @GetMapping("/updateStatus")
    public CommonResult updateStatus(String phone,String name){
        return riderService.updateStatus(phone,name);
    }

    /* *
     * @Author: beisheng
     * @Descriprion: 订单配送完成后骑手账户余额变化，骑手订单统计+1
     * @Date: 2022/10/26 13:50
     * @Return: com.bgs.eat.config.CommonResult
     * @Param: [id,riderId, distributionPrice]
     */

    @GetMapping("todayTask")
    public CommonResult todayTask(Integer id,Integer riderId,Double distributionPrice){
        return riderService.todayTask(id,riderId,distributionPrice);
    }

    /* *
     * @Author: beisheng
     * @Descriprion: 查询骑手今日预计收入，今日完成订单量
     * @Date: 2022/10/26 14:50
     * @Return: com.bgs.eat.config.CommonResult
     * @Param: [riderId]
     */

    @GetMapping("/getAccountOrders")
    public CommonResult getAccountOrders(Integer id){
        return riderService.getAccountOrders(id);
    }

    /* *
     * @Author: beisheng
     * @Descriprion: 根据骑手用户ID查询骑手余额以及今日收入
     * @Date: 2022/10/27 13:37
     * @Return: com.bgs.eat.config.CommonResult
     * @Param: [id]
     */

    @GetMapping("/getRiderMoney")
    public CommonResult getRiderMoney(Integer userProtalId){
        return riderService.getRiderMoney(userProtalId);
    }
}

